<?php

namespace App\Library\Logic;

use App\Library\Requests\Help\HelpPageRequest;
use App\Models\HelpRecordModel;

class HelpRecordLogic extends HelpRecordModel
{

    /**
     *
     * @param HelpPageRequest $request
     * @return array
     *
     */
    public static function recordPaging(HelpPageRequest $request): array
    {
        return paginate(
            self::query()
                ->leftJoin('help', 'help.id', 'help_record.help_id')
                ->leftJoin('shop_user', 'shop_user.user_id', 'help_record.user_id')
                ->where('serial_number', $request->serialNumber)
                ->paginate($request->limit, [
                    'help_record.amount',
                    'shop_user.user_avatar',
                    'shop_user.user_nickname'
                ])
        );
    }
}
